<?php
//call it when client wants the Octoshape status
 header ("content-type: text/xml");
require_once 'TVB/VideoInfrastructure/Server/requires.php';



function viGetOctoStatusBySourceId($source_id) {
		$rf = VideoInfrastructure::getReadableRecordFactory();


		$foundrecord = $rf->find('DistributionOcto', 'source_id = ?  AND octo_status = ?',
					array($source_id,2)
				);
		//print_R($foundrecord);
					$outputdata="";
			
			if ($foundrecord){

						foreach ($foundrecord as $recorddetails) {

						  //echo $recorddetails->export_id;
                          $outputdata.="<videoinfodetails>";
						  $outputdata.="<export_id>".$recorddetails->export_id."</export_id>";
						  $outputdata.="<source_id>".$recorddetails->source_id."</source_id>";
						  $outputdata.="<octo_status>".$recorddetails->octo_status."</octo_status>";
						  $outputdata.="<modify_time>".$recorddetails->modify_time."</modify_time>";
						  $outputdata.="</videoinfodetails>";		
										
						}
					
				}else{
				error_log("ERROR CLASS:" . __CLASS__ . ", FUNCTION: " . __FUNCTION__ . ", LINE: " . __LINE__);
				error_log("call back ID from Octoshape {$source_id} is not correct ");
			}		
					
					
		echo $resultset="<?xml version=\"1.0\"?><videoinfo>".$outputdata."</videoinfo>";			
					
}
			
			
$source_id = isset($_REQUEST['source_id']) ? $_REQUEST['source_id'] : 3819;

viGetOctoStatusBySourceId($source_id);

?>